#pragma once
#include <iostream>





namespace jc
{
	class Date
	{
	public:
		Date(int year = 2025, int month = 3, int day = 3)
			: _year(year) , _month(month), _day(day)
		{
		}
		~Date()
		{
		}
	private:
		int _year;
		int _month;
		int _day;
	};

	template<class T>
	class shared_ptr
	{
	public:
		explicit shared_ptr(T* ptr = nullptr)
			:_ptr(ptr), _pcount(new int(1))
		{
		}

		shared_ptr(const shared_ptr<T>& sp)
			:_ptr(sp._ptr), _pcount(sp._pcount)
		{
			(*_pcount)++;
		}

		void release()
		{
			if (--(*_pcount) == 0)
			{
				delete(_ptr);
				delete(_pcount);
				_ptr = nullptr;
				_pcount = nullptr;
			}
		}

		shared_ptr operator=(const shared_ptr<T>& sp)
		{
			if (this != sp)
			{
				release();

				_ptr = sp._ptr;
				_pcount = sp._pcount;
				*(_pcount)++;
			}
			return *this;
		}

		T& operator*()
		{
			return *_ptr;
		}

		~shared_ptr()
		{
			release();
		}

	private:
		T* _ptr;
		int* _pcount;
	};
}

